package org.yi.fc.enums;

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;

public enum ArticleStatusEnum {

	PUBLISH("publish","已发布"),
	FORBID("forbid","已禁用"),
	UNPUBLISHED("unpublished","未发布"),
	DELETE("delete","已删除");
	
	private String enName;
	private String cnName;
	
	private ArticleStatusEnum(String enName, String cnName) {
		this.enName = enName;
		this.cnName = cnName;
	}

	public String getEnName() {
		return enName;
	}
	public void setEnName(String enName) {
		this.enName = enName;
	}
	public String getCnName() {
		return cnName;
	}
	public void setCnName(String cnName) {
		this.cnName = cnName;
	}
	
	public ArticleStatusEnum parseEnum(String enName){
		Preconditions.checkNotNull(Strings.emptyToNull(enName), "传入的状态值不允许为空!");
		for(ArticleStatusEnum status : values()){
			if(Objects.equal(enName, status.getEnName())) {
				return status;
			}
		}
		return null;
	}
	
}
